package com.bite.springbook.Model;

import lombok.Data;

@Data
public class Result<T> {
    private ResultStatus code;
    private String errmrg;
    private T data;

    public static Result unlogin(){
        Result result = new Result();
        result.setCode(ResultStatus.UNLOGIN);
        result.setErrmrg("用户未登录");
        result.setData(null);
        return result;
    }

    public static <T>Result success(T data){
        Result result = new Result<>();
        result.setData(data);
        result.setCode(ResultStatus.SUCCESS);
        return result;
    }

    public static Result fail(String msg){
        Result result = new Result();
        result.setCode(ResultStatus.FAIL);
        result.setErrmrg(msg);
        return result;
    }
}
